import moduleRegist from '@/utils/moduleRegist';

import { module as instiutionalModule } from './module/institutional';
import { module as commercialModule } from './module/commercial';
// import { module as commercialDetailFromModule } from './module/commercialDetailFrom';
// import { module as addcommercialDetailFromModule } from './module/addcommercialDetailFrom';
// import { module as MerchandiseDetailModule } from './module/MerchandiseDetail';
import { module as merchandiseModule } from './module/merchandise';
import { module as ruleModule } from './module/rule';

const Institutional = resolve => { require(['./Institutional'], resolve); };
const Layout = resolve => { require(['./Layout'], resolve); };
const Commercial = resolve => { require(['./Commercial'], resolve); };
const CommercialDetail = resolve => { require(['./CommercialDetail'], resolve); };
const CommercialDetailFrom = resolve => { require(['./CommercialDetailFrom'], resolve); };
const AddCommercialDetailFrom = resolve => { require(['./AddCommercialDetailFrom'], resolve); };
const Merchandise = resolve => { require(['./Merchandise'], resolve); };
const MerchandiseDetail = resolve => { require(['./MerchandiseDetail'], resolve); };
const Rule = resolve => { require(['./Rule'], resolve); };
const RuleAdd = resolve => { require(['./RuleAdd'], resolve); };
const RuleUpdate = resolve => { require(['./RuleUpdate'], resolve); };
const MerchantSettleRule = resolve => { require(['./MerchantSettleRule'], resolve); };

export default [
  /** 配置管理路由 */
  {
    path: 'tenantCenter',
    redirect: 'tenantCenter/institutional',
    component: Layout,
    meta: {
      title: '商户中心',
      name: '商户中心',
      permission: ['trade:merchant'],
      componentName: 'OrderpayerLayout',
      keepAlive: true,
      icon: 'md-people',
      show: false
    },
    beforeEnter: (to, from, next) => {
    /* eslint-disable */
      moduleRegist(instiutionalModule);
      moduleRegist(commercialModule);
      moduleRegist(ruleModule);
      moduleRegist(merchandiseModule);
      next()
    },
    children: [
      {
        path: 'institutional',
        component: Institutional,
        meta: {
          title: '组织机构管理',
          name: '组织机构管理',
          breadcrumb: '组织机构管理',
          permission: 'trade:merchant:institutional',
          show: true,
          keepAlive: false,
          componentName: 'OrderpayerAddView',
          icon: ''
        }
      },
      {
        path: 'business',
        component: () => import('./other/business'),
        meta: {
          title: '业务管理',
          name: '业务管理',
          breadcrumb: '业务管理',
          permission: 'trade:merchant:business',
          show: true,
          keepAlive: false,
          componentName: 'BusinessManager',
          icon: ''
        }
      },
      {
        path: 'orgBusiness',
        component: () => import('./other/orgBusiness'),
        meta: {
          title: '机构业务管理',
          name: '机构业务管理',
          breadcrumb: '机构业务管理',
          permission: 'trade:merchant:orgBusiness',
          show: true,
          keepAlive: false,
          componentName: 'OrgBusiness',
          icon: ''
        }
      },
      {
        path: 'merchantReg',
        component: () => import('./other/merchantReg'),
        meta: {
          title: '商户进件',
          name: '商户进件',
          breadcrumb: '商户进件',
          permission: 'trade:merchant:merchantReg',
          show: true,
          keepAlive: false,
          componentName: 'MerchantRegManager',
          icon: ''
        }
      },
      {
        path: 'merchantRegDetail',
        component: () => import('./other/merchantRegDetail'),
        meta: {
          title: '进件管理详情',
          name: '进件管理详情',
          breadcrumb: '进件管理详情',
          permission: 'trade:merchant:commercial',
          show: false,
          keepAlive: false,
          componentName: 'MerchantRegDetailView',
          icon: ''
        }
      },

      {
        path: 'commercial',
        component: Commercial,
        meta: {
          title: '商户管理',
          name: '商户管理',
          breadcrumb: '商户管理',
          permission: 'trade:merchant:commercial',
          show: true,
          keepAlive: false,
          componentName: 'OrderpayerAddView',
          icon: ''
        }
      },
      {
        path: 'commercialDetailFrom',
        component: CommercialDetailFrom,
        meta: {
          title: '编辑商户管理',
          name: '编辑商户管理',
          breadcrumb: '编辑商户管理',
          permission: 'trade:merchant:commercial:edit',
          show: false,
          keepAlive: false,
          componentName: 'OrderpayerAddView',
          icon: ''
        }
      },
      {
        path: 'addCommercialDetailFrom',
        component: AddCommercialDetailFrom,
        meta: {
          title: '新增商户管理',
          name: '新增商户管理',
          breadcrumb: '新增商户管理',
          permission: 'trade:merchant:commercial:edit',
          show: false,
          keepAlive: false,
          componentName: 'OrderpayerAddView',
          icon: ''
        }
      },
      {
        path: 'commercialDetail',
        component: CommercialDetail,
        meta: {
          title: '商户管理详情',
          name: '商户管理详情',
          breadcrumb: '商户管理详情',
          permission: 'trade:merchant:commercial',
          show: false,
          keepAlive: false,
          componentName: 'OrderpayerAddView',
          icon: ''
        }
      },

      {
        path: 'merchandise',
        component: Merchandise,
        meta: {
          title: '商品管理',
          name: '商品管理',
          breadcrumb: '商品管理',
          permission: 'trade:merchant:merchandise',
          show: true,
          keepAlive: false,
          componentName: 'OrderpayerAddView',
          icon: ''
        }
      },
      {
        path: 'merchandiseDetail',
        component: MerchandiseDetail,
        meta: {
          title: '商品管理详情',
          name: '商品管理详情',
          breadcrumb: '商品管理详情',
          permission: 'trade:merchant:merchandise',
          show: false,
          keepAlive: false,
          componentName: 'OrderpayerAddView',
          icon: ''
        }
      },
      {
        path: 'merchantSettleRule',
        component: MerchantSettleRule,
        meta: {
          title: '商户清分规则',
          name: '商户清分规则',
          breadcrumb: '商户清分规则',
          permission: 'trade:merchant:rule',
          show: true,
          keepAlive: true,
          componentName: 'MerchantSettleRule',
          icon: ''
        }
      },
      {
        path: 'rule',
        component: Rule,
        meta: {
          title: '商品清分规则',
          name: '商品清分规则',
          breadcrumb: '商品清分规则',
          permission: 'trade:merchant:rule',
          show: true,
          keepAlive: true,
          componentName: 'OrderpayerAddView',
          icon: ''
        }
      },
      {
        path: 'ruleAdd',
        component: RuleAdd,
        meta: {
          title: '商品清分规则新增',
          name: '商品清分规则新增',
          breadcrumb: '商品清分规则新增',
          permission: 'trade:merchant:rule:edit',
          show: false,
          keepAlive: false,
          componentName: 'OrderpayerAddView',
          icon: ''
        }
      },
      {
        path: 'ruleUpdate',
        component: RuleUpdate,
        meta: {
          title: '商品清分规则编辑',
          name: '商品清分规则编辑',
          breadcrumb: '商品清分规则编辑',
          permission: 'trade:merchant:rule:edit',
          show: false,
          keepAlive: false,
          componentName: 'OrderpayerAddView',
          icon: ''
        }
      }
    ]
  }
]
